﻿using System;
using System.Text;
using System.Data;
using System.Data.OleDb;
using System.Collections.Generic;
using System.Reflection;
namespace BLL
{
	 	//Newscont
		public static class LotteryChipped
	{
            private static Data.LotteryChipped Data_Newscont = new Data.LotteryChipped();	
		
		/// <summary>
        /// 添加
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static long Add(Model.LotteryChipped model)
        {
              return Data_Newscont.Add(model);
        }
         /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static int Update(Model.LotteryChipped model)
        {
            return Data_Newscont.Update(model);
        }
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public static bool Delete(long Id)
        {
            return Data_Newscont.Delete(Id);
        }       
        /// <summary>
        /// 单条
        /// </summary>
        /// <param name="Id"></param>
        /// <returns></returns>
        public static Model.LotteryChipped GetModel(long Id)
        {
             return Data_Newscont.GetModel(Id);
        }
        /// <summary>
        /// 上一篇
        /// </summary>
        /// <param name="IndexID"></param>
        /// <param name="tName"></param>
        /// <param name="condition"></param>
        /// <returns></returns>
        public static Model.LotteryChipped Prv(long IndexID, string condition)
        {
            string sql = "";
            if (condition == "")
            {

                sql = "SELECT top 1  * FROM LotteryChipped WHERE Id <" + IndexID + " ORDER BY Id DESC";
            }
            else
            {
                sql = "select top 1 * from LotteryChipped where Id<" + IndexID + " and " + condition + " order by Id desc";
            }

            return Data_Newscont.GetModelBysql(sql);

        }
        public static Model.LotteryChipped NewsTopOne(string sql)
        {
            return Data_Newscont.GetModelBysql(sql);

        }
        /// <summary>
        /// 下一篇
        /// </summary>
        /// <param name="IndexID"></param>
        /// <param name="tName"></param>
        /// <param name="condition"></param>
        /// <returns></returns>
        public static Model.LotteryChipped Next(long IndexID, string condition)
        {
            string sql = "";
            if (condition == "")
            {
                sql = "SELECT top 1 * FROM LotteryChipped WHERE Id >" + IndexID + " ORDER BY Id asc";
            }
            else
            {
                sql = "select top 1 * from LotteryChipped where Id>" + IndexID + " and " + condition + " order by Id desc";
            }
            return Data_Newscont.GetModelBysql(sql);

        }
        /// <summary>
        /// 总数据数
        /// </summary>
        /// <returns></returns>
        public static int GetAll_Count()
        {
            return Data_Newscont.GetAll_Count();
        }        
        /// <summary>
        /// 抽取分页数据
        /// </summary>

        public static List<Model.LotteryChipped> GetPageListBysql(int pageIndex, int pageSize, string sql, out int totalCount)
        {
            return Data_Newscont.GetPageListWhere(pageIndex, pageSize, sql, out totalCount);
        }
        public static List<Model.LotteryChipped> GetPageListBysql2(int pageIndex, int pageSize, string sql, out int totalCount)
        {
            return Data_Newscont.GetPageListWhere2(pageIndex, pageSize, sql, out totalCount);
        }
        public static List<Model.LotteryChipped> GetPageList_Where(int pageIndex, int pageSize, long newsclassid, out int totalCount)
        {          
             return Data_Newscont.GetPageList_Where(pageIndex, pageSize,newsclassid, out totalCount);
        }
        public static List<Model.LotteryChipped> GetPageListWhere(int pageIndex, int pageSize, string lotteryQs, int lotteryType, out int totalCount)
        {
            return Data_Newscont.GetPageListWhere(pageIndex, pageSize, lotteryQs,lotteryType, out totalCount);
        }
        public static DataTable GetPageDT_Where(int PageIndex, int PageSize, long newsclassid, out int totalCount)
        {
            return Data_Newscont.GetPageDT_Where(PageIndex, PageSize, newsclassid, out totalCount);
        }
        public static DataTable GetPageDTWhere(int PageIndex, int PageSize, int lotteryType, string lotteryQs, out int totalCount)
        {
            return Data_Newscont.GetPageDTWhere(PageIndex, PageSize, lotteryType, lotteryQs, out totalCount);
        }
        /// <summary>
        /// 批删
        /// </summary>
        /// <param name="Ids"></param>
        /// <returns></returns>
        public static int Drop(string Ids)
        {
            return Data_Newscont.Drop(Ids);
        }


        public static DataTable GetPageListBysql(string sql)
        {
            return Data_Newscont.GetPageListBysql(sql);
        }
        //----------------------------------------
        public static List<Model.LotteryChipped> GetPageListBysqlsql(int pageIndex, int pageSize, string sql, out int totalCount)
        {
            return Data_Newscont.GetPageListWheresqll(pageIndex, pageSize, sql, out totalCount);
        }


        public static int GetAll_Count(int LotteryChippedId)
        {
            return Data_Newscont.GetAll_Count(LotteryChippedId);
        }
        //----------------------------

        //**************************************************************************************************************************
        /// <summary>
        /// 计算用户战绩
        /// </summary>
        /// <param name="UserId"></param>
        /// <returns></returns>
        public static string ViewModelLevel(long UserId)
        {
            Model.UsersAccount faburenChipped = BLL.UsersAccount.GetModeluser_id(UserId);
            long level = faburenChipped.modellevel;//358998
            string strDiv = "";
            string div1 = "";
            string div2 = "";
            string div3 = "";
            string div4 = "";
            int num = Convert.ToInt32(level) / 9000;//3

            for (int i = 0; i < num; i++)
            {
                div1 += "<img src='../images/crown_9.gif'>";
            }
            int CrownCount = Convert.ToInt32(level) - 9000 * num;//8998
            int CrownNum = CrownCount / 1000;
            if (CrownNum > 0)
            {
                div1 = "<img src='images/crown_" + CrownNum + ".gif'>";
            }
            int level1 = CrownCount % 1000;//998
            int num2 = level1 / 900;
            for (int j = 0; j < num2; j++)
            {
                div2 += "<img src='images/cup_9.gif'>";
            }
            int CupCount = level1 - 900 * num2;
            int CupNum = CupCount / 100;
            if (CupNum > 0)
            {
                div2 = "<img src='images/cup_" + CupNum + ".gif'>";
            }


            int level2 = level1 % 100;
            int num3 = level2 / 90;
            for (int k = 0; k < num3; k++)
            {
                div3 += "<img src='images/medal_9.gif'>";
            }
            int medalCount = level2 - 90 * num3;
            int medal9count = medalCount / 10;
            if (medal9count > 0)
            {

                div3 = "<img src='images/medal_" + medal9count + ".gif'>";
            }

            int level3 = level2 % 10;
            int num4 = level3 / 9;
            for (int z = 0; z < num4; z++)
            {
                div4 += "<img src='images/star_9.gif'>";
            }
            int starCount = level3 - 9 * num4;
            if (starCount > 0)
            {

                div4 = "<img src='images/star_" + starCount + ".gif'>";
            }


            return strDiv = div1 + div2 + div3 + div4;

        }


        public static string ViewModelLevelZhangJi(decimal level)
        {
            //Model.UsersAccount faburenChipped = BLL.UsersAccount.GetModeluser_id(UserId);
            //long level = faburenChipped.modellevel;//358998
            string strDiv = "";
            string div1 = "";
            string div2 = "";
            string div3 = "";
            string div4 = "";
            int num = Convert.ToInt32(level) / 9000;//3

            for (int i = 0; i < num; i++)
            {
                div1 += "<img src='../images/crown_9.gif'>";
            }
            int CrownCount = Convert.ToInt32(level) - 9000 * num;//8998
            int CrownNum = CrownCount / 1000;
            if (CrownNum > 0)
            {
                div1 = "<img src='images/crown_" + CrownNum + ".gif'>";
            }


            int level1 = CrownCount % 1000;//998
            int num2 = level1 / 900;
            for (int j = 0; j < num2; j++)
            {
                div2 += "<img src='images/cup_9.gif'>";
            }
            int CupCount = level1 - 900 * num2;
            int CupNum = CupCount / 100;
            if (CupNum > 0)
            {
                div2 = "<img src='images/cup_" + CupNum + ".gif'>";
            }


            int level2 = level1 % 100;
            int num3 = level2 / 90;
            for (int k = 0; k < num3; k++)
            {
                div3 += "<img src='images/medal_9.gif'>";
            }
            int medalCount = level2 - 90 * num3;
            int medal9count = medalCount / 10;
            if (medal9count > 0)
            {

                div3 = "<img src='images/medal_" + medal9count + ".gif'>";
            }


            int level3 = level2 % 10;
            int num4 = level3 / 9;
            for (int z = 0; z < num4; z++)
            {
                div4 += "<img src='images/star_9.gif'>";
            }
            int starCount = level3 - 9 * num4;
            if (starCount > 0)
            {

                div4 = "<img src='images/star_" + starCount + ".gif'>";
            }


            return strDiv = div1 + div2 + div3 + div4;

        }

        public static string ViewModelLevelByModel(long modellevel)
        {
            //Model.UsersAccount faburenChipped = BLL.UsersAccount.GetModeluser_id(UserId);
            //long level = faburenChipped.modellevel;//358998
            string strDiv = "";
            string div1 = "";
            string div2 = "";
            string div3 = "";
            string div4 = "";
            int num = Convert.ToInt32(modellevel) / 9000;//3

            for (int i = 0; i < num; i++)
            {
                div1 += "<img src='../images/crown_9.gif'>";
            }
            int CrownCount = Convert.ToInt32(modellevel) - 9000 * num;//8998
            int CrownNum = CrownCount / 1000;
            if (CrownNum > 0)
            {
                div1 = "<img src='images/crown_" + CrownNum + ".gif'>";
            }


            int level1 = CrownCount % 1000;//998
            int num2 = level1 / 900;
            for (int j = 0; j < num2; j++)
            {
                div2 += "<img src='images/cup_9.gif'>";
            }
            int CupCount = level1 - 900 * num2;
            int CupNum = CupCount / 100;
            if (CupNum > 0)
            {
                div2 = "<img src='images/cup_" + CupNum + ".gif'>";
            }


            int level2 = level1 % 100;
            int num3 = level2 / 90;
            for (int k = 0; k < num3; k++)
            {
                div3 += "<img src='images/medal_9.gif'>";
            }
            int medalCount = level2 - 90 * num3;
            int medal9count = medalCount / 10;
            if (medal9count > 0)
            {

                div3 = "<img src='images/medal_" + medal9count + ".gif'>";
            }


            int level3 = level2 % 10;
            int num4 = level3 / 9;
            for (int z = 0; z < num4; z++)
            {
                div4 += "<img src='images/star_9.gif'>";
            }
            int starCount = level3 - 9 * num4;
            if (starCount > 0)
            {

                div4 = "<img src='images/star_" + starCount + ".gif'>";
            }


            return strDiv = div1 + div2 + div3 + div4;

        }
        public static List<Model.LotteryChipped> GetPageListBysqlfrom(int pageIndex, int pageSize, string where, string fromTable)
        {
            return Data_Newscont.GetPageListBysqlfrom(pageIndex, pageSize, where, fromTable);
        }

    }
}